package com.changdu.seatunnel.admin.config.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import lombok.Getter;

@Getter
public enum SyncType {
	
    MYSQL_KAFKA("mysql-cdc", "kafka"),
    TIDB_KAFKA("tidb-cdc", "kafka"),
    TICDC_KAFKA("ticdc", "kafka"), 	// 空模板内容
    TIDB_STARROCKS("tidb-cdc", "starrocks"),
    MYSQL_STARROCKS("mysql-cdc", "starrocks"),
    KAFKA_STARROCKS("kafka", "starrocks")
    ;

    @EnumValue
    private final String source;

    private final String sink;
    
    SyncType(String source, String sink) {
        this.source = source;
        this.sink = sink;
    }

	public static SyncType fromCode(String source, String sink) {
		for (SyncType sync : SyncType.values()) {
			if (sync.source.equals(source.toLowerCase()) 
					&& sync.sink.equals(sink.toLowerCase())) {
				return sync;
			}
		}
		throw new IllegalArgumentException("Unknown plugin: " + source + " => " + sink);
	}
	
	public boolean isKafkaSink() {
		return this.sink.equals("kafka");
	}
	
	public boolean isKafkaSource() {
		return this.source.equals("kafka");
	}	
}